﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;

namespace Multivee.UI
{
    public partial class ScreenArrayEditor : Form
    {
        private readonly ScreenArrayEditorController _controller;
        private int _screenCount = 0;

        internal ScreenArrayEditor(ScreenArrayEditorController controller, bool hide)
        {
            InitializeComponent();
            _controller = controller;

            if (hide)
                WindowState = FormWindowState.Minimized;
        }

        private void screenViewEditView1_Load(object sender, EventArgs e)
        {
            ShapeGraph graph = new ShapeGraph();
            graph.Show();
        }

        private void createNewDisplayConfigurationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            _controller.SetScreenArray();
        }

        internal void AddScreen(Control screen)
        {
            flowPanelScreens.Controls.Add(screen);
        }

        internal void RemoveScreen(int index)
        {
            throw new NotImplementedException();
        }

        internal void RemoveScreen(string index)
        {
            throw new NotImplementedException();
        }

        private void loadTileToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void quitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void flowPanelScreens_DoubleClick(object sender, EventArgs e)
        {
            AddScreen();
        }

        private void screenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddScreen();
        }

        private void AddScreen()
        {
            _controller.AddScreen();
        }

        public IList<ScreenEditView> Screens
        {
            get
            {
                List<ScreenEditView> screens = new List<ScreenEditView>(flowPanelScreens.Controls.Count);

                foreach (Control control in flowPanelScreens.Controls)
                {
                    if (control is ScreenEditView)
                        screens.Add((ScreenEditView)control);
                }

                return screens;
            }
        }

        public PropertyGrid PropertyGrid
        {
            get
            {
                return propertyGrid;
            }
        }
    }
}
